package DFA;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.concurrent.atomic.AtomicInteger;

//存储子集合的大集合
public class xBuf extends ArrayList<xBuf> {
    private Integer x1;
    private Integer x2;
    private boolean isInitialized =false;

    public void setInitialized() {
            isInitialized = true;
    }

    @Override
    public String toString() {
        return "xBuf{" +
                "x1=" + x1 +
                ", x2=" + x2 +
                ", isInitialized=" + isInitialized +
                '}';
    }

    public boolean getInitializedState() {
        return isInitialized;
    }

    public xBuf(Integer x1, Integer x2) {
        this.x1 = x1;
        this.x2 = x2;
    }

    public Integer getX1() {
        return x1;
    }

    public void setX1(Integer x1) {
        this.x1 = x1;
    }

    public Integer getX2() {
        return x2;
    }

    public void setX2(Integer x2) {
        this.x2 = x2;
    }

    public boolean isPossessState(int x1, int x2, xBuf xMember, LinkedList X) {
        for (int i = 0; i < X.size(); i++) {
            xBuf o = (xBuf) X.get(i);
            Integer X1state = o.getX1();
            Integer X2state = o.getX2();
            //当且仅当两个状态同时相等时返回false，若有一个不相同则continue，直到循环完毕，然后添加Xmenmber到X中
            if (x1 != X1state || x2 != X2state) {
                continue;
            } else {
                return false;
            }
        }
        X.add(xMember);
        return true;
    }
}
